package mate.task.odin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * This class represents a single item in a to do list.
 * @author Leonard
 * @version 1.0
 */
public class ToDoItem implements Serializable {

	private static final long serialVersionUID = 1L;
	private String name;
	private String description;
	private String tags;
	private String location;
	private Date date;
	private boolean isCompleted;

	/**
	 * Creates a new item with given values
	 * @param name The name (short description) of the item
	 * @param description The full description of the item
	 * @param tags The tags associated with the item, separated by commas/spaces
	 * @param location The location associated with this item
	 * @param date The due date of this task
	 */
	public ToDoItem(String name, String description, String tags, String location, String date) throws Exception{
		this.name = name;
		this.description = description;
		this.location = location;
		this.tags = tags;
		isCompleted = false;

		//parse date String for Date information
		Scanner scan = new Scanner(date);
		scan.useDelimiter("/");

		this.date = new Date(scan.nextInt(),scan.nextInt(),scan.nextInt());
	}

	/**
	 * Marks this task as completed
	 */
	public void complete(){
		isCompleted = true;
	}

	public void undoComplete(){
		isCompleted = false;
	}
	/**
	 * Returns the completion status of this item
	 * @return The completion status of this item
	 */
	public boolean isCompleted(){
		return isCompleted;
	}

	/**
	 * Returns the name of the item
	 * @return The name of the item
	 */
	public String getName(){
		return name;
	}

	/**
	 * Returns the description of the item
	 * @return The description of the item
	 */
	public String getDescription(){
		return description;
	}

	/**
	 * Returns the location of the item
	 * @return The location of the item
	 */
	public String getLocation(){
		return location;
	}

	/**
	 * Returns the date of the item
	 * @return The date of the item
	 */
	public Date getDate(){
		return date;
	}

	/**
	 * Returns a list of the tags associated with the item
	 * @return A list of the tags associated with the item
	 */
	public String getTags(){
		return tags;
	}
}
